package com.yanfan.modbus;


import com.yanfan.common.ByteUtil;
import com.yanfan.modbus.code.ExceptionCode;

/**
 * @author oliver foo
 * @description
 * @date 2024/5/14 16:13
 */
public class ModbusExceptionResult {
    private final String exceptionCode;
    private final String exceptionMessage;

    public ModbusExceptionResult(String exceptionCode, String message) {
        this.exceptionCode = exceptionCode;
        this.exceptionMessage = message;

    }

    public ModbusExceptionResult(byte exceptionCode) {
        this(ByteUtil.dumpHex(exceptionCode), ExceptionCode.getExceptionMessage(exceptionCode));
    }


    public String getExceptionMessage() {
        return exceptionMessage;
    }

    public String getExceptionCode() {
        return exceptionCode;
    }

    @Override
    public String toString() {
        return getExceptionMessage();
    }
}
